﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Recommend.API.Data.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Recommend.API.Data.Mapping
{
    public class ProjectRecommendMap
        : IEntityTypeConfiguration<ProjectRecommend>
    {
        public void Configure(EntityTypeBuilder<ProjectRecommend> builder)
        {
            //Table.
            builder.ToTable("ProjectRecommend");
            //Key.
            builder.HasKey(p=>p.Id);
            //Props.
            builder.Property(p => p.Id)
                .HasColumnName("Id")
                .IsRequired(true);
            builder.Property(p => p.FromUserId)
                 .HasColumnName("FromUserId")
                .IsRequired(true);
            builder.Property(p => p.FromProjectId)
                 .HasColumnName("FromProjectId")
                .IsRequired(true);
            builder.Property(p => p.CreateTime)
                .HasColumnName("CreateTime")
               .IsRequired(true);
            builder.Property(p => p.ProjectName)
                .HasColumnName("ProjectName")
                .HasMaxLength(20)
                .HasDefaultValue("myProject")
                .IsUnicode(true)
                .IsRequired(true);
            builder.Property(p => p.ProjectAvatar)
                .HasColumnName("ProjectAvatar")
                .HasMaxLength(255)
                .HasDefaultValue("https://c.s-microsoft.com/en-us/CMSImages/Image_ProjectManagment_876x505.png?version=fca8dad5-7264-8011-5084-7f0d5d211fbe")
                .IsUnicode(true);
            builder.Property(p => p.ProjectIntroduction)
                .HasColumnName("ProjectIntroduction")
                .HasMaxLength(255)
                .HasDefaultValue("projectIntroduction")
                .IsUnicode(true)
                .IsRequired(true);
        }
    }
}
